{% extends 'base.html' %}
{% block content %}
<h2>编辑订单</h2>
<form method="post">
    {% csrf_token %}
    <table class="table">
        <tr><th>订单号</th><td>{{ order.order_no }}</td></tr>
        <tr><th>套餐</th><td>
            <select name="package" class="form-control" required {% if order.status != 'pending' %}disabled{% endif %}>
                {% for cfg in price_configs %}
                <option value="{{ cfg.package }}" {% if cfg.package == order.package %}selected{% endif %}>{{ cfg.package }} (￥{{ cfg.price }})</option>
                {% endfor %}
            </select>
        </td></tr>
        <tr><th>卡数量</th><td>
            {% if order.status == 'pending' %}
            <input type="number" name="card_count" value="{{ order.card_count }}" min="1" required>
            {% else %}
            {{ order.card_count }}
            {% endif %}
        </td></tr>
        <tr><th>金额</th><td>
            {% if order.status == 'pending' %}
            <input type="number" step="0.01" name="amount" value="{{ order.amount }}" required>
            {% else %}
            {{ order.amount }}
            {% endif %}
        </td></tr>
        <tr><th>收件人</th><td><input type="text" name="receiver" value="{{ order.receiver }}" ></td></tr>
        <tr><th>收货电话</th><td><input type="text" name="delivery_phone" value="{{ order.delivery_phone }}" ></td></tr>
        <tr><th>收货地址</th><td><input type="text" name="delivery_address" value="{{ order.delivery_address }}" ></td></tr>
        <tr><th>备注</th><td>
            {% if order.status == 'pending' %}
            <input type="text" name="remark" value="{{ order.remark }}">
            {% else %}
            {{ order.remark }}
            {% endif %}
        </td></tr>
    </table>
    <button type="submit" class="btn btn-success">保存</button>
    <a href="/orders/" class="btn btn-secondary">取消</a>
</form>
{% endblock %}
